home *** CD-ROM | disk | FTP | other *** search
/ Master Visual Basic 3 / Master Visual Basic 3 (SAMS Publishing) (1994).ISO / mvprog / gendll / gendll.c next >
Encoding:
C/C++ Source or Header  |  1994-04-29  |  2.8 KB  |  100 lines

  1. //-------------------------------------------------------
  2. // GenDLL.C
  3. //-------------------------------------------------------
  4. // Contains code for Generic DLL.
  5. //
  6. // Use the following files as templates for building your
  7. // own DLL:
  8. //
  9. // - GenDLL.C (this file)
  10. // - GenDLL.H
  11. // - GenDLL.DEF
  12. //-------------------------------------------------------
  13.  
  14. #include <windows.h>
  15. #include "GENDLL.H"
  16.  
  17. //------------------------------------------------------
  18. // Global Variables
  19. //------------------------------------------------------
  20. HANDLE hmodDLL;  
  21.  
  22.  
  23. //------------------------------------------------------
  24. // Prototypes
  25. //------------------------------------------------------
  26.  
  27.  
  28. //------------------------------------------------------
  29. // Initialize library. This routine is called when the
  30. // first client loads the DLL.
  31. //------------------------------------------------------
  32. int FAR PASCAL LibMain
  33. (
  34.     HANDLE hModule,
  35.     WORD   wDataSeg,
  36.     WORD   cbHeapSize,
  37.     LPSTR  lpszCmdLine
  38. )
  39. {
  40.     // Avoid warnings on unused formal parameters
  41.     wDataSeg    = wDataSeg;
  42.     cbHeapSize  = cbHeapSize;
  43.     lpszCmdLine = lpszCmdLine;
  44.  
  45.     hmodDLL = hModule;
  46.  
  47.     return 1;
  48. }
  49.  
  50.  
  51.  
  52.  
  53. //------------------------------------------------------
  54. // WEP
  55. //------------------------------------------------------
  56. // C7 and QCWIN provide default WEP:
  57. //------------------------------------------------------
  58. #if (_MSC_VER < 610)
  59.  
  60. int FAR PASCAL WEP(int fSystemExit);
  61.  
  62. //------------------------------------------------------
  63. // For Windows 3.0 it is recommended that the WEP
  64. // function reside in a FIXED code segment and be
  65. // exported as RESIDENTNAME.  This is accomplished
  66. // using the alloc_text pragma below and the related
  67. // EXPORTS and SEGMENTS directives in the .DEF file.
  68. //
  69. // Read the comments section documenting the WEP
  70. // function in the Windows 3.1 SDK "Programmers
  71. // Reference, Volume 2: Functions" before placing
  72. // any additional code in the WEP routine for a 
  73. // Windows 3.0 DLL.
  74. //------------------------------------------------------
  75. #pragma alloc_text(WEP_TEXT,WEP)
  76.  
  77. //------------------------------------------------------
  78. // Performs cleanup tasks when the DLL is unloaded.
  79. // WEP() is called automatically by Windows when the DLL
  80. // is unloaded (no remaining tasks still have the DLL 
  81. // loaded). It is strongly recommended that a DLL have a 
  82. // WEP() function, even if it does nothing but returns 
  83. // success (1), as in this example.
  84. //------------------------------------------------------
  85. int FAR PASCAL WEP
  86. (
  87.     int fSystemExit
  88. )
  89. {
  90.     // Avoid warnings on unused formal parameters
  91.     fSystemExit = fSystemExit;
  92.  
  93.     return 1;
  94. }
  95. #endif // C6
  96.  
  97. //------------------------------------------------------
  98.  
  99.  
  100.